package org.point.service.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.point.common.service.impl.BaseServiceImpl;
import org.point.common.util.DoPage;
import org.point.dao.MemberDao;
import org.point.domain.Member;
import org.point.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 
 * @ClassName: MemberServiceImpl  
 * @Description: TODO(会员单位业务实现类)  
 * @author Kenny_Z' szqiuk@gmail.com
 * @date 2016年10月23日 下午4:02:01  
 *
 */
@Service("memberService")
public class MemberServiceImpl extends BaseServiceImpl<Member, Serializable> implements MemberService {
	
	@Autowired
	private MemberDao dao;

	public DoPage<Member> searchCRForPage(DoPage<Member> page) {
		List<Member> records = dao.searchForMember(page);
		Integer totalRecords = dao.searchForMemberCount(page);
		page.setList(records);
		page.setTotalRecords(totalRecords);
		return page;
	}

	public Integer isLoginA(String account) {
		Integer result = 0;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("account", account);
		Member record = dao.isAccount(map);
		if (record != null) {
			result = 1;
		}
		return result;
	}

	public Member isLoginAP(String account, String password) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("phone", account);
		map.put("password", password);
		Member record = dao.isAccountAndPwd(map);
		return record;
	}
	
	public Integer updateMemberPwd(Map<String, Object> map) {

		Map<String, Object> map_phone = new HashMap<String, Object>();
		map_phone.put("phone", map.get("phone"));
		map_phone.put("password", map.get("password"));
		Member record = dao.isAccountAndPwd(map_phone);
		
		map.put("usersid",record.getId());
		return dao.updateMemberPwd(map);
	}
	
}
